package com.qfedu.firstpage.controller;

import com.qfedu.firstpage.entity.Record;
import com.qfedu.firstpage.entity.RecordExample;
import com.qfedu.firstpage.service.RecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "用户接口")
@RestController
public class RecordController {

    @Autowired
    private RecordService recordService;

    @ApiOperation(value = "获取全部充值记录",produces = "application/json")
    @RequestMapping(value = "/findAllRecord",method = RequestMethod.GET)
  //  @RequestMapping("/findAllRecord")
    public List<Record> findAllRecord(RecordExample recordExample){

        return recordService.selectByExample(recordExample);
    }

    @ApiOperation(value = "书币充值记录",produces = "application/json")
    @RequestMapping(value = "/getRecordByPrimaryKey",method = RequestMethod.GET)
 //   @RequestMapping("/getRecordByPrimaryKey")
    public Record getRecordByPrimaryKey(Integer id){

        return recordService.selectByPrimaryKey(2);
    }

    @ApiOperation(value = "会员充值记录",produces = "application/json")
    @RequestMapping(value = "/getVipUserById",method = RequestMethod.GET)
//    @RequestMapping("/getVipUserById")
    public Record getVipUserById(Integer id){

        return recordService.getVipUserById(1);
    }

    @ApiOperation(value = "消费充值记录",produces = "application/json")
    @RequestMapping(value = "/getExpenditureById",method = RequestMethod.GET)
//  @RequestMapping("/getExpenditureById")
    public Record getExpenditureById(Integer id){

        return recordService.getExpenditureById(2);
    }

    @ApiOperation(value = "会员充值",produces = "application/json")
    @RequestMapping(value = "/insertVIPUser",method = RequestMethod.GET)
//    @RequestMapping("/insert")
    public boolean insertVIPUser(Record record){

        int insert = recordService.insertVIPUser(record);

        if (insert == 0) {

            return false;
        }else {

            return true;
        }
    }
}
